package com.surfilter.msmp.common.util.httpclient;

import java.util.Date;

/**
 * 防止爬虫被封而采取 http或 socket 代理方式进行网页爬取
 */
public class Proxy {

	private int id; // 代理的ID

	private String ip; // 代理IP

	private int port; // 代理的端口号

	private String userName; // 代理的登录用户名

	private String password; // 代理的登录密码

	private boolean needValidate; // 代理是否需要登录

	private int weight; // 代理的权重

	private String source; // 代理的来源类型

	private boolean isHttpProxy = true; // 是否 Http 代理

	private boolean isEffective = true; // 代理是否有效

	private Date ineffectiveTime; // 代理失效的时间

	private Date updateTime; // 代理更新的时间

	private Date createTime; // 代理的创建时间

	private Date validateTime;

	private Integer speed;

	private Integer timeLength;

	private String location;

	private String interfaceObj;

	public Proxy(String ip, int port) {
		this.ip = ip;
		this.port = port;
	}

	public int getId() {
		return id;
	}

	public Date getValidateTime() {
		return validateTime;
	}

	public void setValidateTime(Date validateTime) {
		this.validateTime = validateTime;
	}

	public Integer getSpeed() {
		return speed;
	}

	public void setSpeed(Integer speed) {
		this.speed = speed;
	}

	public Integer getTimeLength() {
		return timeLength;
	}

	public void setTimeLength(Integer timeLength) {
		this.timeLength = timeLength;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getInterfaceObj() {
		return interfaceObj;
	}

	public void setInterfaceObj(String interfaceObj) {
		this.interfaceObj = interfaceObj;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isNeedValidate() {
		return needValidate;
	}

	public void setNeedValidate(boolean needValidate) {
		this.needValidate = needValidate;
	}

	public int getWeight() {
		return weight;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public boolean isHttpProxy() {
		return isHttpProxy;
	}

	public void setHttpProxy(boolean isHttpProxy) {
		this.isHttpProxy = isHttpProxy;
	}

	public boolean isEffective() {
		return isEffective;
	}

	public void setEffective(boolean isEffective) {
		this.isEffective = isEffective;
	}

	public Date getIneffectiveTime() {
		return ineffectiveTime;
	}

	public void setIneffectiveTime(Date ineffectiveTime) {
		this.ineffectiveTime = ineffectiveTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Proxy[");
		sb.append("id=").append(id).append(",");
		sb.append("ip=").append(ip).append(",");
		sb.append("port=").append(port).append(",");
		sb.append("weight=").append(weight).append(",");
		sb.append("isHttpProxy=").append(isHttpProxy).append(",");
		sb.append("ineffectiveTime=").append(ineffectiveTime).append(",");
		sb.append("]\n");
		return sb.toString();
	}
	
	public String getLocalIpAddress() {
		return "localhost";
	}
	
}
